﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Whir.Common.WebHelper;

public partial class Whir_System_Module_Contents_ModelUpdate : System.Web.UI.Page
{
    protected string Action;
    protected int ModelID;
    protected string url;
    protected void Page_Load(object sender, EventArgs e)
    {
        RoleHelper.IsLogin();    //登录判断

        Action = NetRequest.GetQueryString("Action");
        ModelID = NetRequest.GetQueryInt("ModelID");
        url = Server.UrlDecode(NetRequest.GetQueryString("url"));

        if (!IsPostBack)
        {
            BindModel(ModelID);
        }
    }

    /// <summary>
    /// 绑定需修改的功能模块
    /// </summary>
    /// <param name="modelID">功能模块 ID</param>
    private void BindModel(int modelID)
    {
        Whir.Model.Whir_Model model = new Whir.Model.Whir_Model();
        Whir.BLL.Whir_Model bll = new Whir.BLL.Whir_Model();
        model = bll.GetModel(modelID);
        if (model != null)
        {
            txtSysModelName.Text = model.modelName;
            txtSysModelDesc.Text = model.modelDesc;
            lbTableName.Text = model.tableName;
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Action == "Modify")
        {
            Whir.Model.Whir_Model model = new Whir.Model.Whir_Model();
            Whir.BLL.Whir_Model bll = new Whir.BLL.Whir_Model();

            string modelName = txtSysModelName.Text.Trim();
            string modelDesc = txtSysModelDesc.Text.Trim();

            model = bll.GetModel(ModelID);
            model.modelName = modelName;
            model.modelDesc = modelDesc;
            bll.Update(model);
            JsHelper.redirect(Page, "功能模块信息更新成功！", "ModelManage.aspx");
        }
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("ModelManage.aspx");
    }
}
